#ifndef __DFI_H__
#define __DFI_H__

#include <FIPA.h>

#include <Ice/Ice.h>
#include <IceUtil/IceUtil.h>
#include <IceStorm/IceStorm.h>

using namespace std;

class DFI: public FIPA::DF
{
 public:
  DFI
    (Ice::ObjectAdapterPtr);
  ~DFI();

  virtual void _cpp_register
    (const FIPA::DfAgentDescription&, 
     const Ice::Current&);

  virtual void deregister
    (const Ice::Identity&, 
     const Ice::Current&);
  
  virtual void modify
    (const FIPA::DfAgentDescription&, 
     const Ice::Current&);

  virtual FIPA::AgentSeq search
    (const FIPA::DfAgentDescription&, 
     const Ice::Current&);

  virtual void subscribe
    (const FIPA::AgentPrx&,
     const Ice::Current&);

  virtual void unsubscribe
    (const FIPA::AgentPrx&,
     const Ice::Current&);

  virtual void adv
    (const Ice::ObjectPrx&, 
     const Ice::Current&);

  virtual void bye
    (const Ice::Identity&, 
     const Ice::Current&);

  virtual void lookup
    (const Ice::ObjectPrx&, 
     const std::string&, 
     const PropertyService::Properties&, 
     const Ice::Current&);

  virtual void discover
    (const Ice::Current&);

  virtual void notify
    (const FIPA::DFAction&,
     const FIPA::DfAgentDescription&);

 private:
  IceUtil::Mutex _m;
  IceStorm::TopicPrx _df;
  typedef std::map
    <Ice::Identity, FIPA::DfAgentDescription>
    RMap;
  mutable RMap _agents;
};

typedef IceUtil::Handle<DFI> DFIPtr;

#endif
